<?php 
/**
 * 礼品列表 GiftList
 */
class GiftList extends APIBase {

	public $tag = "GiftList";
	public $isLogin = false;

	public function before() {
		$this->initCacheRedis();
		return true;
	}

	public function logic() {
		$giftids = $this->cache_redis->lRange("lgift:ids", 0, -1);
		$gifts = array();
		foreach ($giftids as $gid) {
			$gift = $this->cache_redis->hMGet("hgift:{$gid}", array("name", "price", "charisma"));
			$gift['giftid'] = (int) $gid;
			$gift['name'] = $gift['name'];
			$gift['price'] = (int) $gift['price'];			
			$gift['charisma'] = (int)$gift['charisma'];
			$gifts[] = $gift;
		}
		$this->returnData(array('gifts' => $gifts));
	}

	public function after() {
		$this->deinitCacheRedis();
	}
}

?>